package test4_2.demo02;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Homework19_5 {
    public static void main(String[] args) {
        Map<String,String> lesson= new HashMap<>();

        lesson.put("Tom","CoreJava");
        lesson.put("John","Oracle");
        lesson.put("Susan","Oracle");
        lesson.put("Jerry","JDBC");
        lesson.put("Jim","Unix");
        lesson.put("Kevin","JSP");
        lesson.put("Lucy","JSP");

        //增加新老师教JDBC
        lesson.put("Allen","JDBC");

        //修改Lucy教的课程
        lesson.put("Lucy","CoreJava put");

        //遍历Map
        Set<Map.Entry<String, String>> entrySet = lesson.entrySet();
        for (Map.Entry<String, String> entry : entrySet) {
            System.out.println("老师: " + entry.getKey() + ", 课程: " + entry.getValue());
        }

        //查找教JSP的老师
        for (Map.Entry<String, String> entry : entrySet) {
            if (entry.getValue().equals("JSP")) {
                System.out.println("老师: " + entry.getKey());
            }
        }

    }
}
